/*
 * @Author       : Bing Chen chenbing@iocharger.com
 * @Date         : 2024-12-08 13:40:04
 * @LastEditors  : Bing Chen chenbing@iocharger.com
 * @LastEditTime : 2025-03-15 12:47:53
 * @FilePath     : \openchaoji-corelib\secc\gbt27930\OpenChaoji_secc_gbt27930_b_param_match.c
 * @Description  :
 *
 * Copyright (c) 2025 OpenChaoJi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the icense for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include "../include/OpenChaoJi_secc.h"

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)

int OpenChaoJi_gbt27930_b_secc_param_match(uint8_t fdc_energy, struct OpenChaoJi_gbt27930_b_msg_param_config_evcc param_config_evcc, struct OpenChaoJi_gbt27930_b_msg_param_config_secc param_config_secc)
{
  // 充电参数匹配判断
  if (fdc_energy == 1)
  {
    if(param_config_evcc.parameter_max_charging_volt < param_config_secc.parameter_min_charging_volt ||
       param_config_evcc.parameter_max_charging_curr < param_config_secc.parameter_min_charging_curr)
    {
      return 0;
    }
    else
    {
      return 1;
    }
  }

  // 放电参数匹配判断
  if (fdc_energy == 2)
  {
    if (param_config_evcc.parameter_min_discharge_volt > param_config_secc.parameter_max_discharge_volt ||
       param_config_evcc.parameter_min_discharge_curr > param_config_secc.parameter_max_discharge_curr)
    {
      return 0;
    }
    else
    {
      return 1;
    }
  }

  return 0;
}
#endif
